<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Post extends Admin {

    public function __construct()
    {
        parent::__construct();
        $this->load->model(array("post_model"));
    }
    public function index()
    {
        $data = array();
        $page = $this->uri->segment(4);
        $page_size = 20;
        $param = array();
        $param['keyword'] = $this->input->get('keyword');
        $param['fromdate'] = $this->input->get('fromdate');
        $param['todate'] = $this->input->get('todate');
        $param['parent'] = $this->input->get('parent');
        $param['child'] = $this->input->get('child');
        $param['provinder'] = $this->input->get('provinder_id');
        //$param['email'] = $this->input->get('email');
        $total = $this->post_model->admin_count_all($param);
        $records = $this->post_model->admin_find_all($param,$page, $page_size);
        $page_url = base_url('/cp/post/index');
        $pagination = $this->get_search_paging($page_url, $total, $page, $page_size );

        $data = array(
            "total" => $total,
            "records" => $records,
            "pagination" => $pagination,
            'param'=>$param,
            'provinder'=>$this->all_provinder
        );
        $this->layout->view($data);
    }



    public function edit($id){
        $data = array();
        $data['post']=$this->post_model->getSingle($id);
        $this->load->view('cp/post/edit',$data);
    }
    public function detail($id){
        $data = array();
        $data['post']=$this->post_model->getSingle($id);
        $this->load->view('cp/post/detail',$data);
    }

}